<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单查询页面</title>
    <!-- 引入 Vue 和 Element UI 的样式文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui/lib/theme-chalk/index.css">
    <!-- 引入 Vue、Element UI 和 Axios 的 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.1/lib/index.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
    <el-container>
        <!-- 右侧内容区域 -->
        <el-main>
            <h2>订单列表</h2>
            <el-table :data="orders" style="width: 100%" border>
                <el-table-column prop="orderId" label="订单ID" width="100"></el-table-column>
                <el-table-column prop="userId" label="用户ID"></el-table-column>
                <el-table-column prop="orderDate" label="下单时间"></el-table-column>
                <el-table-column prop="totalAmount" label="总金额"></el-table-column>
                <el-table-column prop="paymentStatus" label="支付状态"></el-table-column>
                <el-table-column prop="shippingAddress" label="配送地址"></el-table-column>
            </el-table>
        </el-main>
    </el-container>
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            orders: [] // 存储订单数据的数组
        },
        created() {
            // 页面加载时获取所有订单列表
            this.getAllOrders();
        },
        methods: {
            // 获取所有订单列表
            getAllOrders() {
                axios.get('/order?operation=getAllOrders')
                    .then(response => {
                        this.orders = response.data.data; // 假设返回的数据格式中有一个 data 字段存储订单列表
                    })
                    .catch(error => {
                        console.error('Error fetching orders', error);
                    });
            }
        }
    });
</script>
</body>
</html>
